package com.tcenter.services.impl;

import com.tcenter.dao.entities.Student;
import com.tcenter.dao.entities.UserRole;
import com.tcenter.dao.providers.StudentDAO;
import com.tcenter.services.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Student: Andrey Pautov
 * Date: 28.05.13
 */
@Service("studentService")
@Scope("request")
@Transactional
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentDAO studentDAO;


    @Override
    public void save(Student student) {
        studentDAO.save(student);
    }

    @Override
    public void update(Student student) {
        studentDAO.update(student);
    }

    @Override
    public void delete(Student student) {
        studentDAO.delete(student);
    }

    @Override
    public Student getById(Integer id) {
        return (Student) studentDAO.getById(id);
    }

    @Override
    public List<Student> getAll() {
        return studentDAO.getAll("Student");
    }

    @Override
    public Student getByEmail(String email) {
        return studentDAO.getByEmail(email);
    }

    @Override
    public List<UserRole> getRolesById(Integer id) {
        return studentDAO.getRolesById(id);
    }


}
